package com.andy.wang.service.impl;

import com.andy.wang.pojo.Chitchat;
import com.andy.wang.pojo.User;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.andy.wang.pojo.Friend;
import com.andy.wang.service.FriendService;
import com.andy.wang.mapper.FriendMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 王更元
* @description 针对表【friend(好友表
)】的数据库操作Service实现
* @createDate 2024-04-07 17:04:09
*/
@Service
public class FriendServiceImpl extends ServiceImpl<FriendMapper, Friend>
    implements FriendService{
    @Autowired
    private FriendMapper friendMapper;

    @Override
    public List<Friend> getFriendAskList(int page, Long uid) {
        page = (page - 1) * 1;
        return friendMapper.getFriendAskList(page,uid);
    }

    @Override
    public List<User> getFriend(Long uid) {
        List<User> userList = friendMapper.getFriend(uid);
        for (User user : userList) {
            user.setChitchat(this.getFriendMassage(uid, user.getUid()));
        }
        return userList;
    }

    @Override
    public Chitchat getFriendMassage(Long userID, Long acceptID) {
        return friendMapper.getFriendMassage(userID, acceptID);
    }
}




